package org.yenn.pattern.aliyun.behavioral.command;

import org.junit.Test;
import org.yenn.pattern.aliyun.behavioral.command.impl.BuyStock;
import org.yenn.pattern.aliyun.behavioral.command.impl.SellStock;

import static org.junit.Assert.*;

/**
 * 步骤 5
 * 使用 Broker 类来接受并执行命令。
 */
public class CommandPatternDemo {
    /**
     * 步骤 6
     * 验证输出。
     *
     * Stock [ Name: ABC, Quantity: 10 ] bought
     * Stock [ Name: ABC, Quantity: 10 ] sold
     */
    @Test
    public void placeOrders() {
        Stock abcStock = new Stock();

        BuyStock buyStockOrder = new BuyStock(abcStock);
        SellStock sellStockOrder = new SellStock(abcStock);

        Broker broker = new Broker();
        broker.takeOrder(buyStockOrder);
        broker.takeOrder(sellStockOrder);

        broker.placeOrders();
    }
}